<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function(){
			//随机0-1之间的值
			// var a=Math.random()*10;  //Math.random()随机0-1之间的值
			// var a=Math.floor(Math.random()*10);//floor(x)取整函数
			// var a=Math.floor(Math.random()*10)+11;
			// var max=78;
			// var min=65;
			// var a=Math.floor(Math.random()*(max-min+1))+min;
			// console.log(a);
			
			//获取随机数
			function ran(max,min){
								var a = Math.floor(Math.random()*(max-min+1))+min;
								return a;
							}
			
			//获取数组
			function fk(a){
								var g = a%10;
								var s = Math.floor(a/10)%10;
								var b = Math.floor(a/100)%10;
								var q = Math.floor(a/1000)%10;
								var w = Math.floor(a/10000)%10;
								var sw = Math.floor(a/100000)%10;
								var bw = Math.floor(a/1000000)%10;
								var arr = [bw,sw,w,q,b,s,g];
								return arr;
							}
							//比较两个数组中有几个数字相同
							function eq(arr1,arr2){
								var count = 0;
								for (var i=0;i<arr1.length;i++) {
									for (var j=0;j<arr2.length;j++) {
										if(arr1[i]==arr2[j]){
											count++;
											break;
										}
									}
								}
								return count;
							}
							//向页面输出
							function sc(text){
								$("#result").val(text);
							}
							$("#bu").on("click",function(){
								var in1 = $("#addent1").val();//获取页面的值
								var in2 = ran(9999999,1000000);
								$("#addent2").val(in2);
								var arr1 = fk(in1);
								var arr2 = fk(in2);
								var count = eq(arr1,arr2);
								switch(count){
									case 7:
										sc("一等奖");
										break;
									case 6:
										sc("二等奖");
										break;
									case 5:
										sc("三等奖");
										break;
									case 4:
										sc("四等奖");
										break;
									case 3:
										sc("五等奖");
										break;
									default:
										sc("未中奖");
										break;
								}
							})
		
			
		})
	</script>
	</head>
	<body>
		输入购买的彩票号码(7位数)：<input type="text" id="addent1"  /><br/>
		<button type="button" id="bu">开奖</button><br/>
		本期开奖的号码：<input type="text" id="addent2" disabled="disabled" /><br/>
		开奖结果：<input type="text" name="" id="result" value=""  disabled="disabled"/>
	</body>
</html>
